package com.jieshen.component;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class requestBox extends Box {

    JFrame jf = null;

    final int WIDTH=850;

    public requestBox(JFrame jf) {
//        super(axis);
        //垂直布局
        super(BoxLayout.Y_AXIS);
        //组装视图
        this.jf = jf;
        JPanel bgPanel = new JPanel();
        bgPanel.setBounds(0,0,WIDTH,600);

        //组装登录相关的元素
        Box mainBox = Box.createVerticalBox();

        //组装用户名
        Box uBox = Box.createHorizontalBox();
        JLabel uLabel = new JLabel("文件所有者:");
        JTextField uField = new JTextField(15);

        uBox.add(uLabel);
        uBox.add(Box.createHorizontalStrut(20));
        uBox.add(uField);

        //组装文件名
        Box fileNameBox = Box.createHorizontalBox();
        JLabel fileNameLabel = new JLabel("文件名:");
        JTextField fileNameField = new JTextField(15);
        fileNameBox.add(fileNameLabel);
        fileNameBox.add(Box.createHorizontalStrut(20));
        fileNameBox.add(fileNameField);

        //组装按钮
        Box okBox = Box.createHorizontalBox();
        JButton okBtn = new JButton("确定");
        okBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //通过socket提交数据

            }
        });
        okBox.add(okBtn);

        mainBox.add(Box.createVerticalStrut(50));
        mainBox.add(uBox);
        mainBox.add(Box.createVerticalStrut(20));
        mainBox.add(fileNameBox);
        mainBox.add(Box.createVerticalStrut(20));
        mainBox.add(okBox);
        bgPanel.add(mainBox);
        this.add(bgPanel);

        this.setVisible(true);
    }

}
